#include<bits/stdc++.h>
using namespace std;
struct node{
    double a;
    double v;
    double d;
    double pos;
};
node car[100001];
double p[100001];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin >> t;
    for(int iii = 1; iii <= t; iii ++){
        for(int i = 1; i <= 100000; i ++) {car[i].a = 0.0; car[i].v = 0.0; car[i].d = 0.0; car[i].pos = 0.0;}
        for(int i = 1; i <= 100000; i ++) p[i] = 0.0;
        int n,m,l,vel;
        cin >> n >> m >> l >> vel;
        for(int i = 1; i <= n; i ++) cin >> car[i].d >> car[i].v >> car[i].a;
        for(int i = 1; i <= m; i ++) cin >> p[i];
        sort(p+1,p+1+m);
        if(car[1].a == 0){
            int ans = 0;
            for(int i = 1; i <= n; i ++)
                if(car[i].v > vel && car[i].d <= p[m]) ans ++;
            cout << ans << ' ';
            double maxd = -114514;
            ans = -1;
            for(int i = 1; i <= n; i ++)
                if(car[i].d <= p[m]) maxd = max(maxd,car[i].d);
            for(int i = m; i >= 1; i --)
                if(p[i] < maxd) {ans = max(0,m - i - 1); break;}
            double mind = INT_MAX;
            for(int i = 1; i <= n; i ++) if(car[i].v > vel) mind = min(mind,car[i].d);
            for(int i = 1; i <= m; i ++)
                if(p[i] >= mind) {ans += (i-1);break;}
            cout << ans << endl;
        }
        if(car[1].a > 0){
            int ans = 0;
            for(int i = 1; i <= n; i ++) car[i].pos = (vel*vel - car[i].v*car[i].v) / 1.0 / (2*car[i].a) + car[i].d;
            for(int i = 1; i <= n; i ++)
                if(car[i].pos < p[m]) ans ++;
            cout << ans << ' ' << endl;
            ans = -1;
            for(int i = 1; i <= n; i ++){
                for(int j = m; j >= 1; j --){
                    if(p[j] <= car[i].pos) {
                        if(ans == -1) ans = max(0,m - j - 1);
                        else ans = min(ans,m-j-1);
                        break;
                    }
                }
            }
            double mind = INT_MAX;
            for(int i = 1; i <= n; i ++) mind = min(mind,car[i].d);
            for(int i = 1; i <= m; i ++)
                if(p[i] >= mind) {ans += (i-1);break;}
            cout << ans << endl;
        }
        if(car[1].a < 0){
            int ans = 0;
            for(int i = 1; i <= n; i ++) car[i].pos = (vel*vel - car[i].v*car[i].v) / 1.0 / (2*car[i].a) + car[i].d;
            for(int i = 1; i <= n; i ++) {
                for(int j = 1; j <= m; j ++)
                    if(p[j] >= car[i].d && p[j] < car[i].pos) ans ++;
                cout << ans << ' ';
                ans = -1;
                for(int i = 1; i <= n; i ++){
                    int cnt1,cnt2;
                    for(int j = 1; j <= m; j ++)
                        if(p[j] >= car[i].d){cnt1 = j;break;}
                    for(int j = m; j >= 1; j --)
                        if(p[j] < car[i].pos){cnt2 = j;break;}
                    if(cnt1 == cnt2) {ans = 0; break;}
                    if(cnt1 > cnt2) {ans = m - cnt1 + 1; break;}
                    if(ans == -1) ans = cnt2 - cnt1;
                    else ans = min(ans,cnt2-cnt1);
                }
                double mind = INT_MAX;
                for(int i = 1; i <= n; i ++) mind = min(mind,car[i].d);
                for(int i = 1; i <= m; i ++)
                    if(p[i] >= mind) {ans += (i-1);break;}
                cout << ans << endl;
            }
        }
    }
    return 0;
}
